String.prototype.trim = function(){
    return $.trim(this);
};

String.prototype.format = function(args){
    var str = this;
    var arr = str.match(/\{(\w+)\}/gi);
    for(var i = 0; i < arr.length; i++){
        var l = arr[i].length;
        str = str.replace(arr[i], args[arr[i].substring(1, l - 1)]);
    }
    return str;
};

String.prototype.pad = function(len, flag, type){
    var str = this;
    if(str.length < len){
        while(str.length < len){
            switch(type){
                case 'l':
                    str = flag + str;
                    break;
                case 'r':
                    str = str + flag;
                    break;
                default:
                    str = str + flag;
                    break;
            }
        }
    }
    return str;
};

jQuery.validator.addMethod('character', function(value){
    return /^\w+$/.test(value);
});

jQuery.validator.addMethod('rangeLength', function(value, element, params){
    return value.length >= params[0] && value.length <= params[1];
});